﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Fleet 
{
    private Dictionary<string, OwnsideShipControllerBase> shipsDict;

   //  public float FCR;
    /// <summary>
    /// 位置
    /// </summary>
    public Vector2 position=Vector2.zero;

    public OwnsideShipControllerBase cargoShip;

    public Fleet()
    {
        shipsDict = new Dictionary<string, OwnsideShipControllerBase>();
    }

    public OwnsideShipControllerBase Remove(string name)
    {
        Debug.Log(name);
        OwnsideShipControllerBase tmp = shipsDict[name];
        shipsDict.Remove(name);
        return tmp;
    }

    public void AddShip(string name,OwnsideShipControllerBase controller,ShipTypes type)
    {
        if (type == ShipTypes.CargoShip)
        {
            cargoShip = controller;
        }
        controller.fleet = this;
        shipsDict.Add(name, controller);
    }

    /// <summary>
    /// 获取当前整体速度
    /// </summary>
    public float GetSpeed()
    {
        List<float> speedList=new List<float>();
        foreach(var item in shipsDict.Values)
        {
            speedList.Add(item.shipModel.Speed);
        }
        speedList.Sort();
        return speedList[0];
    }
}
